package jpm.trade;

import jpm.common.JPMException;
import jpm.trade.TradeHelper.Operation;

import org.junit.Test;

public class TradeHelperTest {
	@Test (expected = JPMException.class)
	public void ensureSameTradeThrowsIfTradeIdMismatch() {
		Trade t1 = new Trade(1, 1, "MSFT", 100, true, "ACC-123", Operation.NEW);
		Trade t2 = new Trade(2, 2, "MSFT", 100, true, "ACC-123", Operation.NEW);
		
		TradeHelper.ensureSameTradeDetails(t1, t2);
	}
	
	@Test (expected = JPMException.class)
	public void ensureSameTradeThrowsIfSecurityMismatch() {
		Trade t1 = new Trade(1, 1, "MSFT", 100, true, "ACC-123", Operation.NEW);
		Trade t2 = new Trade(1, 2, "GOOG", 100, true, "ACC-123", Operation.NEW);
		
		TradeHelper.ensureSameTradeDetails(t1, t2);
	}		
	
	@Test (expected = JPMException.class)
	public void ensureSameTradeThrowsIfAccountMismatch() {
		Trade t1 = new Trade(1, 1, "MSFT", 100, true, "ACC-123", Operation.NEW);
		Trade t2 = new Trade(1, 2, "MSFT", 100, true, "ACC-231", Operation.NEW);
		
		TradeHelper.ensureSameTradeDetails(t1, t2);
	}
}
